package com.example.gybicycle.common.sql;




import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public abstract class CrudService<D extends CrudDao<T>,T> {
    @Autowired(required = false)
    protected  D dao;
    /**
     * 获取单条数据
     */
    public  T get(String id){
        return dao.get(id);
    }
    public  T get(Integer id){
        return dao.get(id);
    }
    public List<String> getQRCode(T entity){
        return dao.getQRCode(entity);
    }
    public  T get(T entity){
        return dao.get(entity);
    }
    public T getByNumber(String number){
        return dao.getByNumber(number);
    }

    /**
     * 添加 单条
     * @param entity
     * @return
     */
    public int insert(T entity){

        return dao.insert(entity);
    }
    /**
     * 批量添加
     * @param list
     * @return
     */
    public int insertByList(List<T> list){
        return dao.insertByList(list);
    }
    /**
     * 修改 单条
     * @param entity
     * @return
     */
    public int update(T entity){
        return dao.update(entity);
    }
     public int updateByOrder(T entity){
        return dao.updateByOrder(entity);
     }


    /**
     * 批量修改
     * @param list
     * @return
     */
    public int updateByList(List<T> list){
        return dao.updateByList(list);
    }
    /**
     * 删除数据 单条
     * @param id
     * @return
     */
    public int delete(Object id){
        return dao.delete(id);
    }


    public int deleteByBatch(List<String> ids){
        return dao.deleteByBatch(ids);
    }
    public List<T> findList(T entity){
        return dao.findList(entity);
    }
    public  String findName(Integer pids){
        return dao.findName(pids);
    }

    public int upByDeadLine(){
        return dao.upByDeadLine();
    }


    /**
     * 条件获取 总数
     * @param entity
     * @return
     */
    public int count(T entity){
        return dao.count(entity);
    }


}
